import pickle
import base64

#封装cookie的加密方法
class CookieSecret(object):
    #加密
    @classmethod
    def dumps(cls,data):
        data_bytes = pickle.dumps(data)
        base64_bytes = base64.b64encode(data_bytes)
        base64_str = base64_bytes.decode()
        return base64_str

    #解密
    @classmethod
    def loads(cls,data):
        base64_bytes = base64.b64decode(data)
        pickle_str = pickle.loads(base64_bytes)
        return pickle_str